/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ucm;

/**
 *
 * @author Stan
 */
import java.sql.*;
import model.UCModel;

public class UCLoginUser extends UCModel{

    public UCLoginUser(String text, String text0) {
        throw new UnsupportedOperationException("Not yet implemented");
    }
    public boolean run() {
        try {
             Statement stmt = DBconnect.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
            ResultSet rset = stmt.executeQuery("select * from user where name = '" + username + "'");
            if (!rset.first())
            {
                System.out.println("USER DOES NOT EXIT");
                return false;
            }
            if (password.equals(rset.getString("password"))) {
                return true;
            } else {
                System.out.println("PASSWORD IS NOT CORRECT");
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}

